You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fix tsvector columns over JSON-mapped navigations/complex properties - #3893
When a property is configured as a generated tsvector column that includes a navigation or complex property mapped to JSON via ToJson(), NpgsqlAnnotationProvider only resolved included names as regular properties, throwing a NullReferenceException instead of finding the underlying JSON container column.
Resolution now also checks navigations and complex properties declared on the same type, resolving them to their JSON container column (including renamed columns) and reporting a clear error for names that don't resolve to a property, navigation, or complex property. Adds unit and functional regression tests covering navigation- and complex-property-based JSON tsvector columns, including renamed and mixed scenarios.
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Fixes design-time migration generation for generated tsvector columns when included names refer to JSON-mapped owned navigations or JSON-mapped complex properties (ToJson()), avoiding the previous NullReferenceException and adding regression coverage.
Changes:
Extend NpgsqlAnnotationProvider tsvector included-name resolution to handle JSON-mapped navigations and complex properties (resolving to the JSON container column).
Add a dedicated error string for unresolved included names (property/navigation/complex property).
Add unit and functional regression tests for JSON-owned navigation/complex-property tsvector scenarios (including renamed/mixed cases).
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.
The error text "Could not find property, navigation or complex property" is also used when the name does resolve to a navigation/complex property but isn't mapped to JSON (i.e. container column name can't be resolved). Consider rewording this message (or adding a separate one) to indicate that the included navigation/complex property must be mapped to a JSON container column via ToJson().
?? throw new InvalidOperationException(
NpgsqlStrings.TsVectorIncludedPropertyNotFound(valueGeneratedProperty.DeclaringType.DisplayName(), p2))
Cover generated tsvector columns over renamed JSON complex properties in migration tests, and clarify errors for included members that cannot resolve to a column.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: fc2f0a76-43ac-437e-82a8-d5a42585d238
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The generated-strings method TsVectorIncludedPropertyNotFound declares its parameters out of the file's appearance-order convention, which risks a silent argument swap if the auto-generated file is regenerated.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Swap included-member parameter order to match message text
This file is marked // <auto-generated /> and follows a consistent convention where each generated method's parameters are ordered by their first appearance in the message text (e.g. SequenceBadType(property, entityType, propertyType) and IncludePropertyNotFound(entityType, property)). Here the message is Included member '{property}' on '{entityType}' ..., so {property} appears first, yet the method declares (object? entityType, object? property). It currently produces the correct message because the call site passes arguments in the same (reversed) order, but this is fragile: if this file is regenerated from the .resx, the parameters will be reordered to (property, entityType), and the existing call site in NpgsqlAnnotationProvider.cs will then silently pass the entity type and member name in swapped positions. Consider ordering the parameters as (property, entityType) to match the convention and updating the call site accordingly.
…erties (#4076)
Backport #3893 to hotfix/10.0.4, adapting GetContainerColumnName to the EF10 API.
(cherry picked from commit fc4430e)
Co-authored-by: Vladimir Nosov <151604979+hostage2222@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
roji
added a commit
that referenced
this pull request
Oct 23, 2026
Backport of #3893 (fc4430e), adapted to EF9 owned-JSON mapping without complex-JSON APIs.
Co-authored-by: Vladimir Nosov <151604979+hostage2222@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
roji
added a commit
that referenced
this pull request
Oct 23, 2026
Backport #3893 (fc4430e), adapting container-column resolution and regression tests for EF8 without complex-JSON mapping support.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a property is configured as a generated tsvector column that includes a navigation or complex property mapped to JSON via
ToJson(),NpgsqlAnnotationProvideronly resolved included names as regular properties, throwing aNullReferenceExceptioninstead of finding the underlying JSON container column.Resolution now also checks navigations and complex properties declared on the same type, resolving them to their JSON container column (including renamed columns) and reporting a clear error for names that don't resolve to a property, navigation, or complex property. Adds unit and functional regression tests covering navigation- and complex-property-based JSON tsvector columns, including renamed and mixed scenarios.
Fixes #3075